MODULE constants_mod
  use spark, only: r_kind, i_kind, pi
  implicit none
  
  integer  ,parameter :: i2  = 2
  integer  ,parameter :: i4  = 4
  integer  ,parameter :: i8  = 8
  integer  ,parameter :: i16 = 16
  integer  ,parameter :: r2  = 2
  integer  ,parameter :: r4  = 4
  integer  ,parameter :: r8  = 8
  integer  ,parameter :: r16 = 16
  
  !real(r_kind),parameter    :: pi        = 2._r16*asin(1._r16)
  real(r_kind),parameter    :: D2R       = PI/180._r16    ! convert degree into radian
  real(r_kind),parameter    :: R2D       = 180._r16/PI    ! convert radian into degree
  real(r_kind),parameter    :: FillValue = -9999999999999999._r16
  real(r_kind),parameter    :: Inf       = huge(Inf)
  real(r_kind),parameter    :: NAN       = transfer(-2251799813685248_i8, 1._r8)
  
  real(r_kind),parameter    :: radius  = 6371220
  real(r_kind),parameter    :: Omega   = 7.292E-5
  real(r_kind),parameter    :: gravity = 9.80616
    
  ! thermal dynamic constants
  real(r_kind),parameter :: Rd  = 287.0583
  real(r_kind),parameter :: Rv  = 461.5233
  real(r_kind),parameter :: p0  = 100000. ! base pressure in Pa
  real(r_kind),parameter :: Md  = 0.0289644
  real(r_kind),parameter :: Mv  = 0.01801528
  real(r_kind),parameter :: eq  = Md / Mv - 1
  real(r_kind),parameter :: Cpd = 1004.5
  real(r_kind),parameter :: Cpv = 1846.
  real(r_kind),parameter :: Cvd = 717.5
  real(r_kind),parameter :: Cvv = 1385.
END MODULE constants_mod
